<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">

    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">

        <h2>View Supplier</h2>
        <h:form id="addSupplierForm" style="font-size: 85%">
            <br/>
            <p:panel>
                <p:messages/>
                <br/>
                <h:panelGrid columns="2" cellpadding="10">

                    <h:outputText value="Supplier Id: " style="font-weight: bold"/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierId}"/>                    

                    <h:outputText value="Supplier Name: " style="font-weight: bold"/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierName}"/>

                </h:panelGrid>

                <br/>
                <br/>
                <h:outputText value="Contact Information" style="font-weight: bold; font-size: 110%"/>
                <p:separator/>
                <br/>
                <p:dataTable id="contacts" var="rec" value="#{supplierManagerBean.supplier.contacts}" emptyMessage="No contacts added.">
                    <p:column headerText="Name" >
                        <h:outputText value="#{rec.name}"/>
                    </p:column>

                    <p:column headerText="Designation" >
                        <h:outputText value="#{rec.jobTitle}"/>
                    </p:column>

                    <p:column headerText="Phone" >
                        <h:outputText value="#{rec.phone}"/>
                    </p:column>

                    <p:column headerText="E-Mail" >
                        <h:outputText value="#{rec.email}"/>
                    </p:column>

                    <p:column headerText="Executive" >
                        <h:outputText value="#{rec.executive?'Yes':'No'}"/>
                    </p:column>

                </p:dataTable>
                
                <br/>
                <br/>
                <br/>
                <h:outputText value="Supplier Address" style="font-weight: bold; font-size: 110%"/>
                <p:separator/>
                <br/>
                <h:panelGrid columns="2" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Address Line 1: "/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierAddress.addressLine1}"/>

                    <h:outputLabel style="font-weight: bold" value="Address Line 2: "/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierAddress.addressLine2}" />

                    <h:outputLabel style="font-weight: bold" value="State: "/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierAddress.stateName}" />

                    <h:outputLabel style="font-weight: bold" value="City: "/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierAddress.city}" />

                    <h:outputLabel style="font-weight: bold" value="Country: "/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierAddress.country}" />

                    <h:outputLabel style="font-weight: bold" value="Zip Code: "/>
                    <h:outputText value="#{supplierManagerBean.supplier.supplierAddress.zipCode}" />
                </h:panelGrid>

                <br/>
                <br/>
                <br/>
                <h:outputText value="Supply Information" style="font-weight: bold; font-size: 110%"/>
                <p:separator/> 
                <br/>
                <p:dataTable id="materials" var="rec" value="#{supplierManagerBean.supplier.rawMaterialsSupplied}" emptyMessage="No raw materials added.">
                    <p:column headerText="Raw Material" >
                        <h:outputText value="#{rec.rawMaterial.name}"/>
                    </p:column>

                    <p:column headerText="Unit Price (SGD) / kg" >
                        <h:outputText value="#{rec.unitPriceSGD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>

                    <p:column headerText="Unit Price (USD) / kg" >
                        <h:outputText value="#{rec.unitPriceUSD}">
                            <f:convertNumber type="currency"/>
                        </h:outputText>
                    </p:column>

                </p:dataTable>
                <br/>
                <br/>
            </p:panel>
            <br/>
            <br/>
            <br/>
            <div align="right">
                <p:commandButton value="Edit Supplier" image="ui-icon ui-icon-pencil" title="Edit Supplier" action="#{supplierListManagerBean.editSupplier(supplierManagerBean.supplier.id)}"/>
                <p:commandButton value="View Supplier List" image="ui-icon ui-icon-note" action="#{supplierListManagerBean.viewSupplierList()}"/>
            </div>
            <br/>
            <br/>
            <br/>
        </h:form>


    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>
